<?
	   layout("/inc/win_layout.html",{title:sysTitle}){
?>
<div class="panel" style="height: 580px; overflow: auto;">
	<div class="panel-body pan">
	<form id="nihao" method="post" action="">
		<div class="row" style="margin-bottom: 10px;">
			<div class="col-lg-12"
				style="width: 600px; float:left; margin-right:-20px; display:inline;">
				<label for="inputUsername" class="col-md-3 control-label">AppName <span class='require'>*</span>
				</label>
				<div class="col-md-12">
					<div class="input-icon">
						<input id="appName" type="text" class="form-control" value=""  placeholder='请输入“AppName”'/>
					</div>
				</div>
			</div>
		</div>
		<div class="row" style="margin-bottom: 10px;">
			<div class="col-lg-12"
				style="width: 600px; float:left; margin-right:-20px; display:inline;">
				<label for="inputUsername" class="col-md-3 control-label">名称 <span class='require'>*</span>
				</label>
				<div class="col-md-12">
					<div class="input-icon">
						<input id="title" type="text" class="form-control" value=""  placeholder='请输入“名称”'/>
					</div>
				</div>
			</div>
		</div>
		<div class="row" style="margin-bottom: 10px;">
			<div class="col-lg-12"
				style="width: 600px; float:left; margin-right:-20px; display:inline;">
				<label for="inputUsername" class="col-md-3 control-label">排序 <span class='require'>*</span>
				</label>
				<div class="col-md-12">
					<div class="input-icon">
						<input id="order" type="text" class="form-control" value=""  placeholder='请输入“排序”'/>
					</div>
				</div>
			</div>
		</div>
		<div class="row" style="margin-bottom: 10px;">
			<div class="col-lg-12"
				style="width: 600px; float:left; margin-right:-20px; display:inline;">
				<label for="inputUsername" class="col-md-3 control-label">注册方式 <span class='require'>*</span>
				</label>
				<div class="col-md-12">
					<div class="input-icon">
						<label>
							<input id="addressType_0" type="radio" name="addressType" value="0" checked="checked"/>&nbsp;自动注册</label>
						<label>
							<input id="addressType_1" type="radio" name="addressType" value="1" onclick="addressListHideShow('1')"/>&nbsp; 手动录入</label>
						<label>
					</div>
				</div>
			</div>
		</div>
		<div class="row" style="margin-bottom: 10px;">
			<div class="col-lg-12"
				style="width: 600px; float:left; margin-right:-20px; display:inline;">
				<label for="inputUsername" class="col-md-3 control-label">机器地址 <span class='require'>*</span>
				</label>
				<div class="col-md-12">
					<div class="input-icon">
						<input id="addressList" type="text" class="form-control" value="" disabled="disabled" placeholder='请输入执行器地址列表，多地址逗分隔'/>
					</div>
				</div>
			</div>
		</div>
		</form>
	</div>
<input type="hidden" name="temp" id="temp"/>
<input type="hidden" name="id" id="id"/>
<br> <br> <br>
</div>
<?} ?>
<script type="text/javascript" src="static/vendors/jquery-validate/jquery.validate.min.js"></script>
<script>
	var index1 = window.parent.getlay();
	$("#id").val(index1);
	$(function() {
 		if (index1 != 0) {
 			demo1();
 		}
	});
	$("input[type='radio']").on('ifChecked', function(event){
		if($("input[name='addressType']:checked").val()=="0"){
			$("#addressList").attr("disabled","disabled");
			$("#addressList").val("");
		}else{
			$("#addressList").removeAttr("disabled");
			$("#addressList").val($("#temp").val());
		}
	});
	function addressListHideShow(ind){
		if(ind=="0"){
			$("#addressList").attr("disabled","disabled");
		}else{
			$("#addressList").removeAttr("disabled");
		}
	}
	function Save(){
		var url="./xxljob_group_save.do";
		if (index1 == 0){//新增
			url="./xxljob_group_save.do";
		}else{//编辑更新
			url="./xxljob_group_update.do";
		}
		$.ajax({
			type : "post",
			url : url,
			data:{
				"id":$("#id").val(),
				"appName":$("#appName").val(),
				"title":$("#title").val(),
				"order":$("#order").val(),
				"addressType":$("input[name='addressType']:checked").val(),
				"addressList":$("#addressList").val()
			},
			dataType : "json",
			async : false,
			success : function(data) {
				if(data.result =="ok"){
					 var index = parent.layer.getFrameIndex(window.name); 
			         window.parent.get();
			         parent.layer.msg("操作成功!", {icon: 6});
			         parent.layer.close(index); 
				}else if(data.result =="no"){
					parent.layer.msg("操作失败!", {icon: 6})
				}else{
					layer.msg(data.result, {icon: 5});
				}
			},
			error : function(data) {
				layer.msg("请求失败！", {icon: 2});
			}
		});
	}
	//获取执行器
	function jobGroup(){
		$.ajax({
			type : "post",
			url : "./xxljob_jobGroup.do",
			data : {
			},
			dataType : "json",
			async : false,
			success : function(data) {
				var html="";
				var dataRole = eval(data);
				for(var i= 0; i< dataRole.length;i++){
					html+='<option value="'+dataRole[i].id+'">'+dataRole[i].title+'</option>';
				}
				$("#jobGroup").append(html); 
			},
			error : function(data) {
				layer.msg("请求失败！", {icon: 2});
			}
		});
	}

function demo1() {
	$.getJSON('./xxljob_group_get.do', {
		id : index1
	//向服务端传的参数，此处只是演示
	}, function(res) {
		//此处仅仅是为了演示变化的内容
		$("#appName").val(res[0].appName);
		$("#title").val(res[0].title);
		$("#order").val(res[0].order);
		if(res[0].addressType=="0"){
			$("#addressType_1").prop("checked",false).parent("div").removeClass("checked");
			$("#addressType_0").prop("checked",true).parent("div").addClass("checked");
			$("#addressList").attr("disabled","disabled");
			$("#addressList").val("");
		}else{
			$("#addressType_0").prop("checked",false).parent("div").removeClass("checked");
			$("#addressType_1").prop("checked",true).parent("div").addClass("checked");
			$("#addressList").removeAttr("disabled");
			$("#addressList").val(res[0].addressList);
			$("#temp").val(res[0].addressList);
		}
	});
};
</script>


